package org.pie.drawing.apps.picimageserver.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.pie.drawing.apps.picimageserver.dto.ImageSearchDTO;
import org.pie.drawing.apps.picimageserver.entity.DustProcessDto;
import org.pie.drawing.apps.picimageserver.entity.DustProcessEntity;
import org.pie.drawing.apps.picimageserver.entity.ImageIndexEntity;
import org.pie.drawing.apps.picimageserver.service.DustProcessService;
import org.pie.drawing.apps.picimageserver.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author zzj
 * @date 2024/09/16 21:03
 **/

@RequiredArgsConstructor
@Api(tags = "沙尘过程")
@CrossOrigin
@RestController
@RequestMapping(value = "dust_process")
public class DustProcessController {
    @Autowired
    private DustProcessService dustProcessService;

    @ApiOperation("获取列表")
    @GetMapping(value = "/list")
    public R list(DustProcessDto dto) {
        List<DustProcessEntity> list = dustProcessService.dustList(dto);
        return R.ok(list);
    }

    @ApiOperation("根据id获取")
    @GetMapping(value = "/getById/{id}")
    public R getById(@PathVariable("id") Long id) {
       return R.ok(dustProcessService.getById(id));
    }

    @GetMapping(value = "/export")
    public void export(DustProcessDto dto, HttpServletResponse response) {
        dustProcessService.export(dto, response);
    }

    @ApiOperation("保存沙尘json入库")
    @GetMapping(value = "/txtSave")
    public void txtSave(String path){
        dustProcessService.txtSave(path);
    }
}
